<!--
 * @Author: luohongbiao
 * @Date: 2022-02-22 10:37:55
 * @LastEditTime: 2022-02-23 10:17:04
 * @LastEditors: luohongbiao1
 * @Description: 
 * @FilePath: \face_problem\设计模式部分\part8\1.发布订阅模式.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>发布订阅模式</title>
</head>

<body>
    <script>
        // 发布-订阅模式，就是观察者模式。当一个对象的状态发生改变时，其他依赖它的对象都将得到通知。
        var salesOffices = {}
        salesOffices.clientList = {}
        salesOffices.listen = function (key, fn) {
            if (!this.clientList[key]) {
                this.clientList[key] = {}
            }
            this.clientList[key].push(fn)
        }
    </script>
</body>

</html>